package com.sunlands.zlcx.usercenter.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * @author anjl
 * @date 1:02 PM 2019/4/15
 * description:
 */
@Data
@Entity(name = "tz_parent_target")
@NoArgsConstructor
@AllArgsConstructor
@Builder
@DynamicUpdate
@DynamicInsert
public class ParentTargetDO implements Serializable {

    private static final long serialVersionUID = 8849588709525896507L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    /**
     * 目标名称
     */
    private String targetName;

    /**
     * 状态
     */
    private Integer status;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    private Integer orders;
    /**
     * 目标类型,考试还是其它
     */
    private Integer targetType;

    @SuppressWarnings("all")
    public enum TargetEnums {
        EXAM(0),
        OTHER(1);
        public final Integer targetType;

        public Integer getTargetType() {
            return targetType;
        }

        TargetEnums(Integer targetType) {
            this.targetType = targetType;
        }

        public static TargetEnums create(Integer targetType) {
            if (null == targetType) {
                return null;
            }
            for (TargetEnums field : TargetEnums.values()) {
                if (targetType.intValue() == field.getTargetType()) {
                    return field;
                }
            }
            return null;
        }
    }

}
